<template>
  <el-dialog
    title="我的信息"
    :visible.sync="visible"
    :append-to-body="true">
    <el-form :model="dataForm" ref="dataForm" label-width="80px">
      <el-form-item label="账号" prop="userName">
        <el-input v-model="dataForm.userName" placeholder="登录帐号"></el-input>
      </el-form-item>
      <el-form-item label="姓名" prop="nickName">
        <el-input v-model="dataForm.nickName" placeholder="用户昵称"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="dataForm.email" placeholder="邮箱"></el-input>
      </el-form-item>
      <el-form-item label="单位" prop="company">
        <el-input v-model="dataForm.company" placeholder="所属单位"></el-input>
      </el-form-item>
      <el-form-item label="手机号" prop="mobile">
        <el-input v-model="dataForm.mobile" placeholder="手机号"></el-input>
      </el-form-item>
      <el-form-item label="状态" size="mini" prop="status">
        <el-radio-group v-model="dataForm.status">
          <el-radio :label="0">禁用</el-radio>
          <el-radio :label="1">正常</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          userName: '',
          nickName:'',
          email: '',
          company: '',
          mobile: '',
          status: 1
        }
      }
    },
    methods: {
      init () {
        this.visible = true
          this.$nextTick(() => {
            this.$refs['dataForm'].resetFields()
            this.$http({
              url: this.$http.adornUrl(`/sys/user/info`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.userName = data.user.username
                this.dataForm.email = data.user.email
                this.dataForm.mobile = data.user.mobile
                this.dataForm.status = data.user.status
                this.dataForm.nickName = data.user.nickName
                this.dataForm.company = data.user.company
              }
            })
          })
      }
    }
  }
</script>
